﻿using System;
using System.Collections.Generic;
using System.Linq;
using Utk.Nlp;

namespace Utk
{
    static class Utils
    {
        public static bool Is(this string input, IClassificator pattern)
        {
            return pattern.Match(input) > 0.8;
        }

        public static bool Is(this string input, Pattern pattern)
        {
            return input.Is(pattern as IClassificator);
        }

        public static IEnumerable<T> Enum<T>(params T[] responses)
        {
            return responses;
        }

        public static IEnumerable<T> Flatten<T>(params IEnumerable<T>[] responses)
        {
            return responses.SelectMany(_ => _);
        }

        public static Tuple<IClassificator, Action<string>> Response(
            IClassificator classificator,
            Action<string> handler)
        {
            return Tuple.Create(classificator, handler);
        }

        public static Tuple<IClassificator, Action<string>> Response(
            Pattern request,
            Pattern response)
        {
            return Response(
                request,
                _ => User.Say(response));
        }
    }
}